﻿/**
*LinearLayout
*auth:lww
*version:1.0
*date:2014-10-11
*/
function LinearLayout(context) {
    this.id = "";
    this.name = "LinearLayout";
    this.version = "1.0.0";
    this.mContext = context;
    this.mLayoutParams = null;
    this.mView = null;
    this.index = 0;
}
LinearLayout.prototype.invalidate = function () {
    if (this.mView == null) {
        this.mView = $c("div", this.getId());
        this.mView.style.backgroundColor = "transparent";
    }
    if (this.mLayoutParams != null) {
        this.mView.style.marginLeft = this.mLayoutParams.getMarginLeft();
        this.mView.style.marginTop = this.mLayoutParams.getMarginTop();
        this.mView.style.marginRight = this.mLayoutParams.getMarginRight();
        this.mView.style.marginBottom = this.mLayoutParams.getMarginBottom();

        this.mView.style.paddingLeft = this.mLayoutParams.getPaddingLeft();
        this.mView.style.paddingTop = this.mLayoutParams.getPaddingTop();
        this.mView.style.paddingRight = this.mLayoutParams.getPaddingRight();
        this.mView.style.paddingBottom = this.mLayoutParams.getPaddingBottom();

        this.mView.style.width = this.mLayoutParams.getWidth();
        this.mView.style.height = this.mLayoutParams.getHeight();
    }
    return this.mView;
};
LinearLayout.prototype.view = function () {
    if (this.mView != null)
        return this.mView;
    return this.invalidate();
};
LinearLayout.prototype.setPositionStyle = function (p) {
    this.invalidate();
    if (this.mView != null) {
        return this.mView.style.position = p;
    }    
};
LinearLayout.prototype.getId = function () {
    if (this.id == null || this.id == "") {
        this.id = id();
    }
    return this.id;
};
LinearLayout.prototype.setId = function (ids) {
    this.id = ids;
};
LinearLayout.prototype.setIndex = function (index) {
    this.index = index;
};
LinearLayout.prototype.setLayoutParams = function (pars) {
    if (pars != null) {
        this.mLayoutParams = pars;
        this.invalidate();
    }
};
LinearLayout.prototype.getLayoutParams = function () {
    return this.mLayoutParams;
};
LinearLayout.prototype.setBackground = function (drawable) {
    if (this.mView != null
        && drawable != null
        && typeof drawable === "object") {
        if (drawable.getBackgroundColor() != null) {
            this.mView.style.backgroundColor = drawable.getBackgroundColor();
        }
        else if (drawable.getBackgroundImageSrc() != null) {
            this.mView.style.backgroundImage = drawable.getBackgroundImageSrc();
            this.mView.style.backgroundRepeat = drawable.getRepeat();
        }
        if (drawable.getBound() != null) {
            this.mView.style.border = drawable.getBound();
        }
    }
};
LinearLayout.prototype.setClassName = function (name, flag) {   
    if (this.mView != null
        && name != null
        && typeof(name) != "undefined") {
        addCss(this.mView, name);    
    }
};
LinearLayout.prototype.setGrative = function (grative) {
    if (this.mView != null) {
        this.mView.style.textAlign = grative;
    }
};
LinearLayout.prototype.setInnerHTML = function (html) {
    if (this.mView != null) {
        this.mView.innerHTML = html;
    }
};
LinearLayout.prototype.addChildView = function (child) {
    if (this.mView != null && child != null) {
        this.mView.appendChild(child);
    }
};
LinearLayout.prototype.getChildViewList = function () {
    if (this.mView != null) {
        return this.mView.childNodes;
    }
};
LinearLayout.prototype.removeAllView = function () {
    if (this.mView != null) {
        this.setInnerHTML("");
    }
};
LinearLayout.prototype.setView = function (child) {
    this.removeAllView();
    this.addChildView(child);
};

markscript("LinearLayout");
//end LinearLayout.js